<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $count = 0;
  $productArray = array();
  
  $selectProduct = "SELECT item.itemName, category.categoryName,subcategory.subCategoryName,item.currentStock, item.maxLevel, item.minLevel
                      FROM item
                      JOIN category ON category.categoryId = item.categoryId
                      JOIN subcategory ON subcategory.subCategoryId = item.subCategoryId
                     WHERE item.currentStock <= item.minLevel
                     ORDER BY item.currentStock ASC";
  $selectProductRes = mysql_query($selectProduct);
  while($row = mysql_fetch_array($selectProductRes))
  {
  	$productArray[$count]['itemName']        = $row['itemName'];
  	$productArray[$count]['categoryName']    = $row['categoryName'];
  	$productArray[$count]['subCategoryName'] = $row['subCategoryName'];
  	$productArray[$count]['currentStock']    = $row['currentStock'];
  	$productArray[$count]['maxLevel']        = $row['maxLevel'];
  	$productArray[$count]['minLevel']        = $row['minLevel'];
  	$count++;
  }
  include("./bottom.php");
  $smarty->assign("productArray",$productArray);
  $smarty->display("productRegister.tpl");
}
?>